<?php

/**
 * XistsUser form.
 *
 * @package    xists
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfPropelFormTemplate.php 10377 2008-07-21 07:10:32Z dwhittle $
 */
class XistsUserForm extends BaseXistsUserForm
{
  public function configure()
  {

		unset(
		    $this['is_activated'], $this['plan_expires_at'],
		    $this['join_date'],
			$this['created_at'], $this['updated_at']
		);
		
		/*
		$this->validatorSchema['username'] = new sfValidatorAnd(array(
			$this->validatorSchema['username'],
			new sfValidatorRegex(array('pattern' => '/[\w]+/')),
		));
		*/

		$this->widgetSchema['gender'] = new sfWidgetFormChoice(array(
			'choices'  => XistsUserPeer::$gender,
			'expanded' => true,
		));
		$this->validatorSchema['gender'] = new sfValidatorAnd(array(
			$this->validatorSchema['gender'],
			new sfValidatorChoice(array('choices' => array_keys(XistsUserPeer::$gender)))
		));
		
		$this->validatorSchema['email'] = new sfValidatorAnd(array(
			$this->validatorSchema['email'],
			new sfValidatorEmail(),
		));

		$this->widgetSchema['passwd']->setAttribute('type', 'password');

		$years = range(date('Y') - 14, date('Y') - 80);
		$this->widgetSchema['dob']->setOption('years', array_combine($years, $years));
		
		$this->widgetSchema['security_answer']->setAttribute('type', 'password');
        
		// join position
		$this->widgetSchema['join_position'] = new sfWidgetFormChoice(array(
			'choices'  => XistsUserPeer::$joinPostion,
			'expanded' => false,
		));
		$this->validatorSchema['join_position'] = new sfValidatorAnd(array(
			$this->validatorSchema['join_position'],
			new sfValidatorChoice(array('choices' => array_keys(XistsUserPeer::$joinPostion)))
		));
		

		$this->widgetSchema->setLabels(array(
			'passwd'      => 'Password',
			'dob'      => 'Date of birth',
			'country_id'    => 'Country',
			'plan_id'    => 'Investment Plan',
		));


  }
}
